import axios from "axios";
import config from "@/util/config";

const http = axios.create({
    baseURL: config.serverIp,
    withCredentials: true
});

http.interceptors.response.use((response) => {
    //查看response中是否含有tokenError: 404
    let tokenError = response.data.tokenError;

    if (tokenError != undefined && tokenError == '404'){
        window.location.replace(config.webIp);
    }else{
        return response;
    }
}, (error) => {
    // 对响应错误做点什么
    return Promise.reject(error);
});

export default http;